var userApplication = {
	createNew: function() {
		
		var application = {};
		//登录
		application.userLogin = function(requestData, loginli, loginedli) {
			$.ajax({
				type: "GET",
				data: requestData,
				url: CONFIGER_MANAGER.DOMAIN + "ajax_login",
				dataType: 'json',
				async: true
			}).done(function(data) {

				if (data.success) {
					if (loginli.length && loginedli.length) {
						loginli.fadeOut(1000);
						loginedli.show();
						var login_a = $(window.frames['header'].document).find(".login>a");
						login_a.html("退出");
						$("#logined_username").html(data.nickname);
					} else {
						window.location.href = "managelogined.html";
					}
					setLocalStorage(STORATE_MANAGER.user, data.data)
				} else {
					$.toast("账户或者密码不正确");
				}
			}).fail(function(data) {

			}).always(function() {

			});

		};

		//申请入驻
		application.applySettled = function() {
			//申请入驻
			$("#applysettled").on("click", function() {
				if ($("#contactperson").val() == "") {
					$.toast("请填写联系人");
					return;
				}
				if( !isChineseName($("#contactperson").val()) ){
					$.toast("请填写正确的联系人姓名，2至5个汉字");
					return;					
				}
				if ($("#mobileno").val() == "") {
					$.toast("手机号");
					return;
				}
				if(!isTelephone($("#mobileno").val())){
					$.toast("请填写正确的手机号");
					return;
				}
				if ($("#qq").val() == "") {
					$.toast("请填写qq");
					return;
				}
				if(!isQQ($("#qq").val())){
					$.toast("请填写正确的qq");
					return;					
				}
				var requestData = {
					contact_person: $("#contactperson").val(),
					mobile_no: $("#mobileno").val(),
					qq: $("#qq").val(),
					mail: $("#mail").val(),
					merchant_name: $("#merchantname").val(),
					merchant_type: $("#merchanttype").val(),
					description: $("#description").val(),
				};
//				requestData = {
//					contact_person: "张三",
//					mobile_no: "15381105360",
//					qq: "344252323",
//					mail: "344252323@qq.com",
//					merchant_name: "公司名紫",
//					merchant_type: "公司类型",
//					description: "公司描述",
//				};
				$.ajax({
					type: "GET",
					url: CONFIGER_MANAGER.DOMAIN + "ajax_apply_settled",
					data: requestData,
					async: true,
					dataType: "JSON"
				}).done(function(data) {
					$.toast(data.data.settled_result);
				});
			});
		};
	
		return application;
	}
};

var thisUserApplication = userApplication.createNew();